<template>
	<view>
		<view class="tops">
			<van-row>
			  <van-col span="5" ><span @tap="gotoAdd()">我要提问</span></van-col>
			  <van-col span="14">
				  <input type="text" value="" placeholder="请输入查询的关键字" v-model="title" class="inpu"/>
			  </van-col>
			  <van-col span="5"><span>搜索答案</span></van-col>
			</van-row>
		</view>
			<!-- 答案区 -->
			<view  v-for="(item,index) in resultList" :key="index" class="result" @tap="openUrl(item.id)">
				<van-row >
				  <van-col span="3"><image :src=item.vater mode="widthFix"></image></van-col>
				  <van-col span="18">
					  <view class="">{{item.title}}</view>
					  <view class="">{{item.body}}</view>
				  </van-col>
				  <van-col span="3"><span class="nums">{{item.num}}</span></van-col>
				</van-row>
			</view>

		<view class="isOver" v-if="isOver">------我是有底线的------</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:'',
				pageindex:1,
				isOver:'false',
				resultList:[
					 {
						id:'1',
						vater:'https://pcsdata.baidu.com/thumbnail/885208fd0td3cc82ad59d4aa60767433?fid=3725398796-16051585-244819177793148&rt=pr&sign=FDTAER-yUdy3dSFZ0SVxtzShv1zcMqd-mwa3BrTdUklWNOYA60jH%2FDRjwzE%3D&expires=2h&chkv=0&chkbd=0&chkpc=&dp-logid=194611098787787982&dp-callid=0&time=1667458800&bus_no=26&size=c1600_u1600&quality=100&vuk=-&ft=video',
						title:"测试",
						body:"test",
						num:2,
					}
				],
			}
		},
		methods: {
			openUrl(data){
				uni.navigateTo({
					url:'/pages/help/eachHelpAddResult?id='+data
				})
			},
			async getResultList(){
							const res = await this.$myRuquest({
								//在调用数据接口时传参页码变成动态数据
								//url:'/api/getResultList?pageindex='+this.pageindex
							})
							console.log(this.pageindex)
							console.log(res);
							//此处是为了在下拉刷新时将之前数据塞进去，否则之前数据将丢失
							this.resultList=[...this.resultList,...res.data.message];
							// this.goods=res.data.message;
						},
						// 下拉到底部后加载新数据
			onReachBottom(){
							//判断下一页是否存在数据，不存在将显示暂无数据等提示语
							if(this.goods.length<this.pageindex*10){
								this.isOver=true;
							}
							this.pageindex++;//页数加一
							this.getHotGoods();//回调接口
						},
			gotoAdd(){
				uni.navigateTo({
					url:'/pages/help/eachHelpAddParam'
				})
			},
		}
	}
</script>

<style lang="scss">
.tops{
	margin: 15rpx;
	background-color: cadetblue;
	border-radius: 20rpx;
	.inpu{
		background-color: white;
	}
}
.result{
	margin-left: 5rpx;
	margin-right: 5rpx;
	border-bottom: lightgrey solid 1px;
	background-color: #ffffff;
}
.nums{
		color: white;
		display:block;
		background:#f00;
		border-radius:50%;
		width:18px;
		height:18px;
		margin-top: 10rpx;
		text-align: center;
}
.isOver{
	text-align: center;
	color: lightgray;
}

</style>
